
public class HandshakePacket {
	
	//VARIABLES
	byte[] data;
	String peerId;
	
	public HandshakePacket(String peerId)
	{
		this.data = new byte[32];
		this.peerId = peerId;
	}
	
	public byte[] handshakeMessage()
	{
		//First Part of Message
		String header = "CEN5501C2008SPRING";
		byte[] headerArray = header.getBytes();
		
		for(int i=0; i < headerArray.length; i++)
			data[i] = headerArray[i];
		
		//Second Part - 10-byte zero bits
		for(int i=headerArray.length; i < 10; i++)
			data[i] = 0;
		
		//Cnverts the peerId to bytes and appends to data
		byte[] peerIdBytes = peerId.getBytes();
		
		for(int i = 28; i < 32; i++)
			data[i] = peerIdBytes[i-28];
		
		return data;
	}
	
	/*
	public static void main(String args[]) throws Exception
	{
		HandshakePacket h = new HandshakePacket("1002");
		byte[] message = h.handshakeMessage();
		
		for(int i=0; i<32; i++)
			System.out.print(message[i]);
		
		System.out.println("\nMessage = "+new String(message));
	}
	*/

}
